<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 
            new 执行过程
                1. 后面跟着函数名(),调用了构造函数
                2. 创建了一个空对象，this就是对象名
                3. 给当前对象，动态添加属性和方法
                4. 返回这个对象
        */

        function Hero (name,age,level){
            this.age = age;
            this.level = level;
            this.name = name;

            this.skill = function(){
                console.log('释放了技能');
            }
        }

        let lvbu = new Hero('吕布', 22 , 18);
        console.log(lvbu.name);
        console.log(lvbu['level']);
        lvbu.skill();
    </script>
</body>
</html>